package com.pw.study.structure;

import java.util.LinkedList;

public class Hello {
    public static void main(String[] args) {
        int k1 = fun2(5, 3);
        System.out.println(k1);

    }

    public static int fun(int n, int m) {
        if (n == 1) {
            return 0;
        }
        int x = fun(n - 1, m);
        System.out.println("----" + x);
        return (m + x) % n;
    }

    public static int fun2(int n, int m) {
        int result = 0;
        for (int i = 2; i <= n; i++) {
            result = (m + result) % i;
            System.out.println("====" + result);
        }
        return result;
    }

}
